# -*- coding: utf-8 -*-
import numpy as np
from sim_skynet import *

#%%

feature = np.load("../data/skynet_feature_int32_HWC.npz")
weight = np.load("../data/skynet_weight_int32_KKC_OCIC.npz")
hls = np.load("../data/hls_debug.npy")
# hls = hls.astype(np.int16)
# hls = hls.reshape(160, 320, 3)

img = feature["data0"]

# im2col
# pad = np.pad(img, ((1, 1), (1, 1), (0, 0)), "constant", constant_values=128)
# con = []
# for i in range(3):
#     for j in range(3):
#         con.append(pad[i: i+160, j: j+320, ...])
# swu = np.concatenate(con, axis=2)
# swu = swu.reshape(160, 320, 9, 3)

# dwconv
# dwconv = dwLayer(img, weight["L0-W"], weight["L0-B"], weight["L0-M"], 128)
# wrong = np.argwhere(dwconv != hls)

# bypass
# conv6 = feature["conv6"].reshape(20, 2, 40, 384)
# gold = feature["reorg"].reshape(20, 40, 2, 384)

# for i in range(2):
#     for j in range(40):
#         print(i, j, np.all(conv6[:, i, j, :] == gold[:, j, i, :]))

# hls = hls.reshape(20, 40, 2 * 384)

# output
hls = hls.astype(np.int16)
hls = hls.reshape(20, 40, 10)
gold = feature["conv13"]
wrong = np.argwhere(gold != hls)
